<?php

// for http://ae.grandcloud.cn
$services = getenv("VCAP_SERVICES");
if ($services==''&&!defined('SAE_MYSQL_USER')) { 
	define('DB_NAME', 'mgjhxvredi_core');
	define('DB_USER', 'mgjhxvredi_core');
	define('DB_PASSWORD','tanLVemGvW');
	define('DB_HOST', 'localhost');
	define('DB_PORT', '3306');
	define('SHOW_SCRIPT_NAME',false);
}else if(defined('SAE_MYSQL_USER')){
	//for sina app engine
	define('DB_NAME', SAE_MYSQL_DB);
	define('DB_USER', SAE_MYSQL_USER);
	define('DB_PASSWORD', SAE_MYSQL_PASS);
	define('DB_HOST', SAE_MYSQL_HOST_M);
	define('DB_PORT', SAE_MYSQL_PORT);
	define('SHOW_SCRIPT_NAME',false);
}else{
	//for  sheng da egine
	$services_json = json_decode($services,true);
	$mysql_config = $services_json["mysql-5.1"][0]["credentials"];
	// ** MySQL settings from resource descriptor ** //
	define('DB_NAME', $mysql_config["name"]);
	define('DB_USER', $mysql_config["user"]);
	define('DB_PASSWORD', $mysql_config["password"]);
	define('DB_HOST', $mysql_config["hostname"]);
	define('DB_PORT', $mysql_config["port"]);
	define('SHOW_SCRIPT_NAME',true);
}


// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
	'name'=>'Hroze Soft',
	'sourceLanguage'=>'en_us',
	'language'=>'zh_cn',

	// preloading 'log' component
	'preload'=>array('log','bootstrap'),

	// autoloading model and component classes
	'import'=>array(
		'application.models.*',
		'application.components.*',
		'application.modules.user.models.*',
        'application.modules.user.components.*',
	),
	'modules'=>array(
    'gii'=>array(
        'generatorPaths'=>array(
            'bootstrap.gii',
        ),
    ),
    'user'=>array(
            # encrypting method (php hash function)
            'hash' => 'md5',
 
            # send activation email
            'sendActivationMail' => true,
 
            # allow access for non-activated users
            'loginNotActiv' => false,
 
            # activate user on registration (only sendActivationMail = false)
            'activeAfterRegister' => false,
 
            # automatically login from registration
            'autoLogin' => true,
 
            # registration path
            'registrationUrl' => array('/user/registration'),
 
            # recovery password path
            'recoveryUrl' => array('/user/recovery'),
 
            # login form path
            'loginUrl' => array('/user/login'),
 
            # page after login
            'returnUrl' => array('/user/profile'),
 
            # page after logout
            'returnLogoutUrl' => array('/user/login'),
        ),
),

	'defaultController'=>'post',

	// application components
	'components'=>array(
		/**'user'=>array(
			// enable cookie-based authentication
			'allowAutoLogin'=>true,
			
		),**/
		'user'=>array(
            // enable cookie-based authentication
            'class' => 'WebUser',
            'allowAutoLogin'=>true,
            'loginUrl' => array('/user/login'),
        ),
		/**
		'db'=>array(
			'connectionString' => 'sqlite:protected/data/blog.db',
			'tablePrefix' => 'tbl_',
		),
		**/
		// uncomment the following to use a MySQL database
		
		'db'=>array(
			'connectionString' => 'mysql:host='.DB_HOST.';dbname='.DB_NAME,
			'emulatePrepare' => true,
			'username' => DB_USER,
			'password' => DB_PASSWORD,
			'charset' => 'utf8',
			'tablePrefix' => 'tbl_',
		),
		
		'errorHandler'=>array(
			// use 'site/error' action to display errors
			'errorAction'=>'site/error',
		),
		'urlManager'=>array(
			'urlFormat'=>'path',
			'showScriptName'=>SHOW_SCRIPT_NAME,
			'rules'=>array(
				'login'=>'user/login',
				'contact'=>'site/contact',
				'page/<view:.*?>' =>'site/page',
				'blog'=>'post/index',
				'blog/<id:\d+>/<title:.*?>'=>'post/view',
				'blog/<tag:.*?>'=>'post/index',
				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
			),
		),
		'log'=>array(
			'class'=>'CLogRouter',
			'routes'=>array(
				array(
					'class'=>'CFileLogRoute',
					'levels'=>'error, warning',
				),
				// uncomment the following to show log messages on web pages
				/*
				array(
					'class'=>'CWebLogRoute',
				),
				*/
			),
		),
		'bootstrap'=>array(
        'class'=>'ext.bootstrap.components.Bootstrap', // assuming you extracted bootstrap under extensions
        'responsiveCss'=>true
   		 ),
	),

	// application-level parameters that can be accessed
	// using Yii::app()->params['paramName']
	'params'=>require(dirname(__FILE__).'/params.php'),
);